home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Graphic Gems I, II & III (C_C++) / Graphics Gems C Code.sea / GemsI / Src / PolyScan / poly.h < prev    next >
Text File  |  1992-06-16  |  2KB  |  56 lines

  1. /* poly.h: definitions for polygon package */
  2.  
  3. #ifndef POLY_HDR
  4. #define POLY_HDR
  5.  
  6. #define POLY_NMAX 8        /* max #sides to a polygon; change if needed */
  7.  
  8. typedef struct {        /* A POLYGON VERTEX */
  9.     double sx, sy, sz, sw;    /* screen space position (sometimes homo.) */
  10.     double x, y, z;        /* world space position */
  11.     double u, v, q;        /* texture position (sometimes homogeneous) */
  12.     double r, g, b;        /* (red,green,blue) color */
  13.     double nx, ny, nz;        /* world space normal vector */
  14. } Poly_vert;
  15. /* update poly.c if you change this structure */
  16.  
  17. typedef struct {        /* A POLYGON */
  18.     int n;            /* number of sides */
  19.     int mask;            /* interpolation mask for vertex elems */
  20.     Poly_vert vert[POLY_NMAX];    /* vertices */
  21. } Poly;
  22. /*
  23.  * mask is an interpolation mask whose kth bit indicates whether the kth
  24.  * double in a Poly_vert is relevant.
  25.  * For example, if the valid attributes are sx, sy, and sz, then set
  26.  *    mask = POLY_MASK(sx) | POLY_MASK(sy) | POLY_MASK(sz);
  27.  */
  28.  
  29. typedef struct {        /* A BOX (TYPICALLY IN SCREEN SPACE) */
  30.     double x0, x1;        /* left and right */
  31.     double y0, y1;        /* top and bottom */
  32.     double z0, z1;        /* near and far */
  33. } Poly_box;
  34.  
  35. typedef struct {        /* WINDOW: A DISCRETE 2-D RECTANGLE */
  36.     int x0, y0;            /* xmin and ymin */
  37.     int x1, y1;            /* xmax and ymax (inclusive) */
  38. } Window;
  39.  
  40. #define POLY_MASK(elem) (1 << (&poly_dummy->elem - (double *)poly_dummy))
  41.  
  42. #define POLY_CLIP_OUT 0        /* polygon entirely outside box */
  43. #define POLY_CLIP_PARTIAL 1    /* polygon partially inside */
  44. #define POLY_CLIP_IN 2        /* polygon entirely inside box */
  45.  
  46. extern Poly_vert *poly_dummy;    /* used superficially by POLY_MASK macro */
  47.  
  48. void    poly_print(/* str, p */);
  49. void    poly_vert_label(/* str, mask */);
  50. void    poly_vert_print(/* str, v, mask */);
  51. int    poly_clip_to_box(/* p1, box */);
  52. void    poly_clip_to_halfspace(/* p, q, index, sign, k, name */);
  53. void    poly_scan(/* p, win, pixelproc */);
  54.  
  55. #endif
  56.